from rest_framework import serializers
from goods.models import SPUSpecification


class SpecsSerializer(serializers.ModelSerializer):
    spu = serializers.StringRelatedField(read_only=True)
    spu_id = serializers.IntegerField()

    class Meta:
        model = SPUSpecification
        fields = ("id","name","spu","spu_id")

    # {
    #     "counts": "SPU商品规格总数量",
    #     "lists": [
    #         {
    #             "id": "规格id",
    #             "name": "规格名称",
    #             "spu": "SPU商品名称",
    #             "spu_id": "SPU商品id"
    #         },
    #         ...
    #     ],
    #     "page": "页码",
    #     "pages": "总页数",
    #     "pagesize": "页容量"
    # }